
import { _decorator, Component, Node, Vec3 } from 'cc';
import { CamreaCtrl } from '../game/CamreraCtrl';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = JoyStickManager
 * DateTime = Sun Feb 25 2024 11:49:09 GMT+0800 (中国标准时间)
 * Author = heyongtao
 * FileBasename = JoyStickManager.ts
 * FileBasenameNoExtension = JoyStickManager
 * URL = db://assets/scripts/utils/JoyStickManager.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */
 
@ccclass('JoyStickManager')
export class JoyStickManager extends Component {
    static instance : JoyStickManager = null;
    public static GetInstance()
    {
        if(!JoyStickManager.instance)
        {
            JoyStickManager.instance = new JoyStickManager();
        }
        return JoyStickManager.instance;
    }
    //虚拟摇杆组件
    joyStick: any = null;
    //速度
    speed: Vec3 = new Vec3(5, 5, 0);
 
    onLoad() {
        JoyStickManager.GetInstance().joyStick = this.node.getComponent("JoyStick");
    }
 
    start() {
 
    }
 
    update() {
        if(JoyStickManager.GetInstance().joyStick.moving)
        {
            CamreaCtrl.GetInstance().updateCamera();
        }
    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
